$(function () {
    selectGroup();
})
function selectGroup() {
    let data1 = {groupNumber:localStorage.getItem("groupNumber")};
    console.log(data1);
    dataGroup = myAjax("/group/selectGroup",data1,"post");
    let data = dataGroup.list;
    let html ='';
    for (let i = 0 ;i<data.length;i++){
        html+='<tr>' +
            '<td>'+data[i].id+'</td>\n' +
            '            <td>'+data[i].groupName+'</td>\n' +
            '            <td>'+data[i].personnelName+'</td>\n' +
            '            <td>'+data[i].personnelSex+'</td>\n' +
            '            <td>'+data[i].personnelPhone+'</td>\n' +
            '            <td>'+data[i].leaderName+'</td>\n' +
            '</tr>'
    }
    $("#personnelManage").html(html);
    if ((data[0].leaderName)===(localStorage.getItem("username"))){
        $("#botton").html('<button class="layui-btn layui-btn-lg" onclick="dianDao()" type="button">点到</button>');
    }
}
function dianDao() {
    let personnelName = localStorage.getItem("username");
    let myDate = new Date();
    let seperator1 = "-";
    var year = myDate.getFullYear();
    let month = myDate.getMonth() + 1;
    let strDate = myDate.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    let currentdate = year + seperator1 + month + seperator1 + strDate;
    let data1 = {
        personnelName:personnelName,
        diandaoTime: currentdate,
    }
    let result = myAjax("/dianDao/selectToday",data1,"post");
    if (result.result == 0){
        $("#body").load("dianDao.html");
    }else {
        alert("今日已点名");
    }

}